using System.Collections.Generic;
using System.Data.Linq;
using Magiq.Support;

namespace Magiq.Providers.Sql.Insert
{
    public class EntitySetInsertDestination<TDestination, TNew> : IInsertDestination<TNew>
        where TDestination : class
        where TNew : class, TDestination, new()
    {
        private readonly EntitySet<TDestination> entitySet;

        public EntitySetInsertDestination(EntitySet<TDestination> list)
        {
            entitySet = list;
        }

        #region IInsertDestination<TNew> Members

        public void Insert(IEnumerable<TNew> items)
        {
            foreach (var item in items)
                entitySet.Add(item);
        }

        #endregion
    }
}